#region Using Directives

using System;
using Microsoft.Practices.ComponentModel;
using Microsoft.Practices.RecipeFramework;

using EnvDTE;
using EnvDTE80;

#endregion

namespace EEst.SoftwareFactory.Actions
{
    class AddVCPPProjectToSolutionFolderAction : Action
    {
        #region Input Properties

        [Input]
        public string ProjectFile
        {
            get { return projectFile; }
            set { projectFile = value; }
        } string projectFile;

        [Input]
        public Project TargetFolder
        {
            get { return targetFolder; }
            set { targetFolder = value; }
        }
        Project targetFolder;

        #endregion

        #region Output Properties

        [Output]
        public Project AddedProject
        {
            get { return addedProject; }
            set { addedProject = value; }
        } Project addedProject;

        #endregion

        #region IAction Members

        public override void Execute()
        {
            SolutionFolder folder = (SolutionFolder)targetFolder.Object;
            addedProject = folder.AddFromFile(projectFile);
//            TraverseProjects(targetFolder);
        }

        private void TraverseProjects(Project project)
        {
            foreach (ProjectItem item in project.ProjectItems)
            {
                if (item is Project)
                {
                    Project child = item as Project;
                    string name = child.Name;
                    string projectFileName = child.Kind;
                    TraverseProjects(child);
                }
            }
        }

        public override void Undo()
        {
            throw new Exception("The method or operation is not implemented.");
        }

        #endregion
    }
}
